using MediatR;
using Microsoft.AspNetCore.Http;
using WMS.Common;
using WMS.Domain;

namespace WMS.Api.Application.Commands
{
    #region 入库类型命令

    /// <summary>
    /// 获取入库类型列表命令
    /// </summary>
    public class GetInboundTypeListCommand : IRequest<ApiResult<List<InboundTypeDto>>>
    {
    }

    /// <summary>
    /// 入库类型DTO
    /// </summary>
    public class InboundTypeDto
    {
        /// <summary>
        /// 入库类型ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 类型名称
        /// </summary>
        public string TypeName { get; set; } = string.Empty;
    }

    #endregion

    #region 入库单命令

    /// <summary>
    /// 获取入库单列表命令
    /// </summary>
    public class GetInboundOrderListCommand : IRequest<ApiResult<PagingResult<List<InboundOrderDto>>>>
    {
        /// <summary>
        /// 页码
        /// </summary>
        public int PageIndex { get; set; } = 1;

        /// <summary>
        /// 每页大小
        /// </summary>
        public int PageSize { get; set; } = 10;

        /// <summary>
        /// 仓库ID
        /// </summary>
        public int? WarehouseId { get; set; }

        /// <summary>
        /// 入库类型ID
        /// </summary>
        public int? InboundTypeId { get; set; }

        /// <summary>
        /// 参考号
        /// </summary>
        public string? ReferenceNo { get; set; }
    }

    /// <summary>
    /// 获取入库单详情命令
    /// </summary>
    public class GetInboundOrderByIdCommand : IRequest<ApiResult<InboundOrderDetailDto>>
    {
        /// <summary>
        /// 入库单ID
        /// </summary>
        public int Id { get; set; }
    }

    /// <summary>
    /// 创建入库单命令
    /// </summary>
    public class CreateInboundOrderCommand : IRequest<ApiResult<int>>
    {
        /// <summary>
        /// 入库单信息
        /// </summary>
        public InboundOrderCreateDto InboundOrder { get; set; }
    }

    /// <summary>
    /// 更新入库单命令
    /// </summary>
    public class UpdateInboundOrderCommand : IRequest<ApiResult<int>>
    {
        /// <summary>
        /// 入库单信息
        /// </summary>
        public InboundOrderUpdateDto InboundOrder { get; set; }
    }

    /// <summary>
    /// 删除入库单命令
    /// </summary>
    public class DeleteInboundOrderCommand : IRequest<ApiResult<int>>
    {
        /// <summary>
        /// 入库单ID
        /// </summary>
        public int Id { get; set; }
    }

    /// <summary>
    /// 上传入库单附件命令
    /// </summary>
    public class UploadInboundAttachmentCommand : IRequest<ApiResult<string>>
    {
        /// <summary>
        /// 入库单ID
        /// </summary>
        public int InboundOrderId { get; set; }

        /// <summary>
        /// 附件类型
        /// </summary>
        public string AttachmentType { get; set; }

        /// <summary>
        /// 文件
        /// </summary>
        public IFormFile File { get; set; }
    }

    /// <summary>
    /// 入库单列表DTO
    /// </summary>
    public class InboundOrderDto
    {
        /// <summary>
        /// 入库单ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 仓库ID
        /// </summary>
        public int WarehouseId { get; set; }

        /// <summary>
        /// 仓库名称
        /// </summary>
        public string WarehouseName { get; set; } = string.Empty;

        /// <summary>
        /// 入库类型ID
        /// </summary>
        public int InboundTypeId { get; set; }

        /// <summary>
        /// 入库类型名称
        /// </summary>
        public string InboundTypeName { get; set; } = string.Empty;

        /// <summary>
        /// 体积
        /// </summary>
        public decimal? Volume { get; set; }

        /// <summary>
        /// 预计到达时间
        /// </summary>
        public DateTime? EstimatedArrivalTime { get; set; }

        /// <summary>
        /// 港口出发时间
        /// </summary>
        public DateTime? PortDepartureTime { get; set; }

        /// <summary>
        /// 港口到达时间
        /// </summary>
        public DateTime? PortArrivalTime { get; set; }

        /// <summary>
        /// 参考号1
        /// </summary>
        public string? ReferenceNo1 { get; set; }

        /// <summary>
        /// 参考号2
        /// </summary>
        public string? ReferenceNo2 { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; }
    }

    /// <summary>
    /// 入库单详情DTO
    /// </summary>
    public class InboundOrderDetailDto : InboundOrderDto
    {
        /// <summary>
        /// 入库明细列表
        /// </summary>
        public List<InboundItemDto> Items { get; set; } = new List<InboundItemDto>();

        /// <summary>
        /// 附件列表
        /// </summary>
        public List<InboundAttachmentDto> Attachments { get; set; } = new List<InboundAttachmentDto>();
    }

    /// <summary>
    /// 入库单创建DTO
    /// </summary>
    public class InboundOrderCreateDto
    {
        /// <summary>
        /// 仓库ID
        /// </summary>
        public int WarehouseId { get; set; }

        /// <summary>
        /// 入库类型ID
        /// </summary>
        public int InboundTypeId { get; set; }

        /// <summary>
        /// 体积
        /// </summary>
        public decimal? Volume { get; set; }

        /// <summary>
        /// 预计到达时间
        /// </summary>
        public DateTime? EstimatedArrivalTime { get; set; }

        /// <summary>
        /// 港口出发时间
        /// </summary>
        public DateTime? PortDepartureTime { get; set; }

        /// <summary>
        /// 港口到达时间
        /// </summary>
        public DateTime? PortArrivalTime { get; set; }

        /// <summary>
        /// 参考号1
        /// </summary>
        public string? ReferenceNo1 { get; set; }

        /// <summary>
        /// 参考号2
        /// </summary>
        public string? ReferenceNo2 { get; set; }

        /// <summary>
        /// 入库明细列表
        /// </summary>
        public List<InboundItemCreateDto> Items { get; set; } = new List<InboundItemCreateDto>();
    }

    /// <summary>
    /// 入库单更新DTO
    /// </summary>
    public class InboundOrderUpdateDto
    {
        /// <summary>
        /// 入库单ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 仓库ID
        /// </summary>
        public int WarehouseId { get; set; }

        /// <summary>
        /// 入库类型ID
        /// </summary>
        public int InboundTypeId { get; set; }

        /// <summary>
        /// 体积
        /// </summary>
        public decimal? Volume { get; set; }

        /// <summary>
        /// 预计到达时间
        /// </summary>
        public DateTime? EstimatedArrivalTime { get; set; }

        /// <summary>
        /// 港口出发时间
        /// </summary>
        public DateTime? PortDepartureTime { get; set; }

        /// <summary>
        /// 港口到达时间
        /// </summary>
        public DateTime? PortArrivalTime { get; set; }

        /// <summary>
        /// 参考号1
        /// </summary>
        public string? ReferenceNo1 { get; set; }

        /// <summary>
        /// 参考号2
        /// </summary>
        public string? ReferenceNo2 { get; set; }

        /// <summary>
        /// 入库明细列表
        /// </summary>
        public List<InboundItemUpdateDto> Items { get; set; } = new List<InboundItemUpdateDto>();
    }

    /// <summary>
    /// 入库明细DTO
    /// </summary>
    public class InboundItemDto
    {
        /// <summary>
        /// 明细ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 入库单号
        /// </summary>
        public string OrderId { get; set; } = string.Empty;

        /// <summary>
        /// 商品SKU
        /// </summary>
        public string Sku { get; set; } = string.Empty;

        /// <summary>
        /// 商品名称
        /// </summary>
        public string ProductName { get; set; } = string.Empty;

        /// <summary>
        /// 数量
        /// </summary>
        public int Quantity { get; set; } = 1;

        /// <summary>
        /// 箱号
        /// </summary>
        public string? BoxNo { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string? Remark { get; set; }

        /// <summary>
        /// 单价
        /// </summary>
        public decimal? UnitPrice { get; set; }
    }

    /// <summary>
    /// 入库明细创建DTO
    /// </summary>
    public class InboundItemCreateDto
    {
        /// <summary>
        /// 商品SKU
        /// </summary>
        public string Sku { get; set; } = string.Empty;

        /// <summary>
        /// 数量
        /// </summary>
        public int Quantity { get; set; } = 1;

        /// <summary>
        /// 箱号
        /// </summary>
        public string? BoxNo { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string? Remark { get; set; }

        /// <summary>
        /// 单价
        /// </summary>
        public decimal? UnitPrice { get; set; }
    }

    /// <summary>
    /// 入库明细更新DTO
    /// </summary>
    public class InboundItemUpdateDto
    {
        /// <summary>
        /// 明细ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 商品SKU
        /// </summary>
        public string Sku { get; set; } = string.Empty;

        /// <summary>
        /// 数量
        /// </summary>
        public int Quantity { get; set; } = 1;

        /// <summary>
        /// 箱号
        /// </summary>
        public string? BoxNo { get; set; }

        /// <summary>
        /// 备注
        /// </summary>
        public string? Remark { get; set; }

        /// <summary>
        /// 单价
        /// </summary>
        public decimal? UnitPrice { get; set; }
    }

    /// <summary>
    /// 入库附件DTO
    /// </summary>
    public class InboundAttachmentDto
    {
        /// <summary>
        /// 附件ID
        /// </summary>
        public int Id { get; set; }

        /// <summary>
        /// 入库单号
        /// </summary>
        public string OrderId { get; set; } = string.Empty;

        /// <summary>
        /// 附件类型
        /// </summary>
        public string AttachmentType { get; set; }

        /// <summary>
        /// 文件路径
        /// </summary>
        public string FilePath { get; set; } = string.Empty;

        /// <summary>
        /// 上传状态
        /// </summary>
        public string UploadStatus { get; set; }
    }

    #endregion
} 